$(function(){
    $('#editForm').form("clear");

   $(".user-changepassword").click(function(){
       $('#changepasswordContent').dialog({
           title:'修改密码',
           width:280,
           height:170,
           modal:true,
           closed:true,
           top:150,
           href:"user/changePassword",
           buttons:[{
               text:'确定',
               iconCls:'icon-ok',
               handler:okHandler
           },{
               text:'取消',
               handler:function(){
                   $('#changepasswordContent').dialog('close');
               }
           }]
       });
       $('#changepasswordContent').dialog('open');
   });

    function okHandler(){
        $('#editForm').form('submit',{
            onSubmit: function(){
                if($(this).form('validate')){
                    var new1 = $("#password_new").val()   ;
                    var new2 = $("#password_new2").val() ;
                    if(new1 != new2) {
                        $.messager.show({
                            title: 'Error',
                            msg: '两次输入的密码不一致'
                        });
                        return false;
                    }
                    return true;
                } ;
                return false;
            },
            success: function(data) {
                var data = eval('('+data+')');
                if (data.status == '1'){
                    $('#changepasswordContent').dialog('close');
                } else {
                    $.messager.show({
                        title: 'Error',
                        msg: data.msg
                    });
                }
            }

        });
    };

    $("#bd_layout").layout();

})

